package com.whz.generic.api;

import com.google.common.collect.Maps;
import lombok.Data;
import org.springframework.util.Assert;

import java.util.Map;

/**
 * 标准化接口Api入参包装类
 *
 * @author whz
 */
@Data
public class ApiRequestWrapper<T> {
    private Map<String, String> header = Maps.newHashMapWithExpectedSize(0);

    private T payLoad;

    public static <T> ApiRequestWrapper<T> of(T payload) {
        ApiRequestWrapper<T> request = new ApiRequestWrapper<>();
        request.setPayLoad(payload);
        return request;
    }

    public ApiRequestWrapper<T> withHeader(Map<String, String> headers) {
        Assert.notEmpty(headers, "headers empty.");
        getHeader().putAll(headers);
        return this;
    }

}